Skip to content

fix(server-utils): Avoid directly importing tracingChannel for Node v18 compatibility#21662

Merged
Lms24 merged 3 commits into
developfrom
timfish/fix/node-v18-issues
Jun 22, 2026
Merged

fix(server-utils): Avoid directly importing tracingChannel for Node v18 compatibility#21662
Lms24 merged 3 commits into
developfrom
timfish/fix/node-v18-issues

Conversation

@timfish

@timfish timfish commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes another usage of tracingChannel which isn't supported in Node v18.0.0.

I also added a test to ensure we don't break this again at import time.

@timfish timfish marked this pull request as ready for review June 19, 2026 16:17
@timfish timfish requested a review from a team as a code owner June 19, 2026 16:17
@timfish timfish requested review from JPeer264, Lms24 and andreiborza and removed request for a team June 19, 2026 16:17
setupOnce() {
DEBUG_BUILD && debug.log(`[orchestrion:mysql] subscribing to channel "${CHANNELS.MYSQL_QUERY}"`);
const queryCh = tracingChannel(CHANNELS.MYSQL_QUERY);
const queryCh = diagnosticsChannel.tracingChannel(CHANNELS.MYSQL_QUERY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The change to a namespace import introduces a runtime TypeError on Node.js <18.19.0 when mysqlChannelIntegration is used, as diagnosticsChannel.tracingChannel will be undefined.
Severity: MEDIUM

Suggested Fix

Add a runtime check to ensure diagnosticsChannel.tracingChannel is a function before calling it. This will prevent the TypeError on older Node.js versions where the API does not exist, effectively guarding the integration's setup.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/integrations/tracing-channel/mysql.ts#L76

Potential issue: The change from a named import to a namespace import (`import * as
diagnosticsChannel`) prevents a load-time crash on Node.js versions below 18.19.0.
However, it introduces a new runtime bug. On these older Node versions,
`diagnosticsChannel.tracingChannel` is `undefined`. When the `mysqlChannelIntegration`
is initialized, its `setupOnce()` method is called, which attempts to execute
`diagnosticsChannel.tracingChannel(...)`. This results in a `TypeError:
diagnosticsChannel.tracingChannel is not a function`, crashing the application at
runtime during SDK initialization.

Also affects:

  • packages/node-core/src/integrations/pino.ts:130
  • packages/opentelemetry/src/tracingChannel.ts:56

Did we get this right? 👍 / 👎 to inform future reviews.

@andreiborza andreiborza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea putting this on ci!

@Lms24 Lms24 changed the title fix: More Node v18 issues fix(server-utils): Avoid directly importing tracingChannel for Node v18 compatibility Jun 22, 2026
@Lms24 Lms24 merged commit 6e11be3 into develop Jun 22, 2026
216 checks passed
@Lms24 Lms24 deleted the timfish/fix/node-v18-issues branch June 22, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants